package com.social.controller;


import com.social.dao.EsActivityRepository;
import com.social.pojo.Result;
import com.social.service.EsActivityService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;



/**
 * @author zero
 */
@RestController
@RequestMapping("/es")
public class EsActivityController {
    @Resource
    private EsActivityService EsActivityService;
    @Autowired
    private EsActivityRepository esActivityRepository;

    @GetMapping("/getAll")
    public Result getAll(){
        return Result.ok(200,esActivityRepository.findAll());
    }

    @GetMapping("/esSearch")
    public Result esSearch(@RequestParam("key") String key) {
        return EsActivityService.searchactivity(key);
    }
    @GetMapping("/esSearchTitleHits")
    public Result esSearchTitleHits(@RequestParam("key")String key) {
        return EsActivityService.searchTitleWithHits(key);
    }
    @GetMapping("/esSearchTitleOrDescHits")
    public Result esSearchTitleOrDescHits(@RequestParam("key")String key) {
        return EsActivityService.searchTitleOrDescWithHits(key);
    }
}